package com.继承.基础;

import java.util.Objects;

public class Object_1 {
    String name ;
    int age;

    public Object_1(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Object_1{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Object_1 object1 = (Object_1) o;
        return age == object1.age && Objects.equals(name, object1.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    public static void main(String[] args) {
        Object_1 object1 = new Object_1("zhangsan",18);
        Object_1 object2 = new Object_1("zhangsan",18);

    }
}
